package wechat.subject;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.driver.SpecialConvert;
import com.filter.BaseController;

import beans.subject.subinfo;
import beans.user.suberror;
import beans.user.subresult;
import beans.user.user;
import service.subject.SubInfoServiceImpl;
import service.user.SubErrorServiceImpl;
@Controller
@RequestMapping("/wxsubject")
public class CKaoShiController extends BaseController{

	@Resource
	private SubErrorServiceImpl<suberror> subErrorServiceImpl;
	
	@Resource
	private SubInfoServiceImpl<subinfo> subInfoServiceImpl;
	
	@RequestMapping("/kaoshi")
	public String kaoshi(String drivertype,String special) {
		getReq().setAttribute("drivertype", drivertype);
		getReq().setAttribute("special", SpecialConvert.SpecialConvertInfo(special));
		return "wechat/subject/kaoshi";
	}

	@RequestMapping("/error")
	public String error(String drivertype,String special,String infotype) {
		getReq().setAttribute("drivertype", drivertype);
		getReq().setAttribute("special", special);
		getReq().setAttribute("infotype", infotype);
		return "wechat/subject/error";
	}
	
	@RequestMapping("/errorload")
	@ResponseBody
	public void errorload() {
		Map<String,String> m = new HashMap<>();

		user u = (user)getReq().getSession().getAttribute("wxuser");
		try {
			String[] errlist = getReq().getParameterValues("errlist[]");
			if(errlist!=null) {
				subErrorServiceImpl.deletebyid(errlist,u.getId());
			}
		} catch (Exception e) {
			e.printStackTrace();
		}

		m.put("url", "/wx/index");
		responseJson(m);
	}
}
